import { get, post } from '@/utils/request.js'
import Config from '@/config'

export default {
  getBrief(id) {
    return get(Config.API_VERSION + '/TargetClients/PhaseProgress/GetClientInfo', { ClientOrgID: id })
  },
  getPermissions(id) {
    return get('/ClientPage/GetClientPages', { ClientID: id })
  },
  // padding clients 操作项
  getApplyOptions(id) {
    return get('/Power/Apply/Options', { clientOrgID: id })
  },
  // target clients 操作项
  getOperations(id) {
    return get('/Power/Target/Options', { clientOrgID: id })
  },
  // existing clients 操作项
  getExistingClientOperations(id) {
    return get('/Power/Existing/Options', { clientOrgID: id })
  },
  getBackgroundInfo(id) {
    return get(Config.API_VERSION + '/ServicePrice/GetClientCBGInfo', { ClientID: id })
  },
  saveBackgroundInfo(applyId, clientId, baseInfo, demandInfo) {
    const data = {}
    baseInfo.client = clientId
    demandInfo.forEach(demand => (demand.client = clientId))
    data.apply = applyId
    data.clientCBG = baseInfo
    data.clientCBGDemandTypes = demandInfo
    return post(Config.API_VERSION + '/ServicePrice/SaveClientCBGInfo', data)
  },
  getSaleUser(clientId) {
    return get('/Power/Target/GetSaleUser', { clientOrgID: clientId })
  },
  getSharedUser(id) {
    return get('/Power/Target/GetClientShareUser', {
      clientOrgID: id
    })
  },
  getClientOwnerCandidate(id) {
    return get('Power/Existing/GetSaleUserList', {
      clientOrgID: id
    })
  },
  saveSharePersons(id, data) {
    return post('/Power/Target/UpdateShareOption', {
      clientOrgID: id,
      empIDs: data.persons
    })
  },
  setClientStatus(id, type, ownerBy = undefined, reason = undefined) {
    return post('/Power/Target/UpdateOptions', {
      clientOrgID: id,
      operateType: type,
      ownerBy,
      reason
    })
  },
  changeClientOwner(clientId, newOwner, reason) {
    return post('/Power/Existing/UpdateOwner', {
      clientOrgID: clientId,
      owner: newOwner,
      reson: reason
    })
  },
  approveClient(id) {
    return get(Config.API_VERSION + '/Admin/TargetClients/ApproveClientOrgApply', { clientID: id })
  },
  rejectClient(id, reason) {
    return post(Config.API_VERSION + '/Admin/TargetClients/RejectClientOrgApply', { clientID: id, reason: reason })
  },
  submitClient(id) {
    return get(Config.API_VERSION + '/TargetClients/SubmitClientOrgApply', { clientID: id })
  },
  deletePendingClient(id) {
    return get(Config.API_VERSION + '/TargetClients/DeleteClientOrgApply', { clientID: id })
  },
  getPendingClientPreviewInfo(id) {
    return get(Config.API_VERSION + '/TargetClients/GetClientOrgApply', { clientID: id })
  },
  isAllowReturn(id) {
    return get('/Power/Target/IsCanReturnClient', { clientOrgID: id })
  },
  getApplyExtensionDetail(id) {
    return get(Config.API_VERSION + '/TargetClients/Contract/GetClientContratExtensionDetail', { ID: id })
  },
  approveExtension(id) {
    return get(Config.API_VERSION + '/Admin/Others/ContractExtension/ApproveClientContractExtesion', { ID: id })
  },
  rejectExtension(id, clientId, reason) {
    return post(Config.API_VERSION + '/Admin/Others/ContractExtension/RejectClientContractExtension', {
      id: id,
      clientID: clientId,
      reason: reason
    })
  },
  getApplyRevivalDetail(id) {
    return get(Config.API_VERSION + '/Reconnect/GetReconnectApply', { applyID: id })
  },
  approveRevival(id) {
    return get(Config.API_VERSION + '/Admin/Reconnect/ApproveClientReconnect', { applyID: id })
  },
  rejectRevival(id, reason) {
    return get(Config.API_VERSION + '/Admin/Reconnect/RejectClientReconnect', { applyID: id, reason: reason })
  },
  terminateRevival(id, reason) {
    return get(Config.API_VERSION + '/Reconnect/TerminateReconnect', { clientID: id, reason: reason })
  }
}
